import { useState } from 'react';
import { Button } from 'antd';
import { useBasicDataStore } from "@/stores/basicDataStore";
import { useCmpDataStore } from '@/stores/cmpDataStore';
import BaseStoreSearch from './BaseStoreSearch';
import type { StoreInfo } from '@/Interface/StoreInfoInterface';

const CmpStoreSearch = () => {
  const setBasicData = useBasicDataStore(state => state.setBasicData);
  const setCmpData = useCmpDataStore(state => state.setCmpData);
  const [searchStore, setSearchStore] = useState<StoreInfo | null>(null);

  return (
    <BaseStoreSearch
      // 选中门店时暂存到本地状态（差异化回调）
      onSelect={(store) => setSearchStore(store)}
      // 添加额外按钮（差异化配置）
      extraButtons={
        <>
          <Button
            color="primary"
            variant="solid"
            onClick={() => searchStore && setBasicData(searchStore)}
          >
            设为当前门店
          </Button>
          <Button
            color="primary"
            variant="solid"
            onClick={() => searchStore && setCmpData(searchStore)}
          >
            设为对比门店
          </Button>
        </>
      }
    />
  );
};

export default CmpStoreSearch;